package com.yex.controller.modify.merchant;


import com.yex.common.exception.RRException;
import com.yex.common.utils.R;
import com.yex.common.validator.ValidatorUtils;
import com.yex.entity.UserEntity;
import com.yex.service.modify.merchant.ApiMerchantService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/appApi/merchant")
public class ApiMerchantController {

    @Autowired
    private ApiMerchantService apiMerchantService;

    @PostMapping("register")
    public R register(UserEntity userEntity, HttpServletRequest request) {
        if (StringUtils.isBlank(userEntity.getMerchantLinkman())) throw new RRException("请输入商户联系人");
        if (StringUtils.isBlank(userEntity.getMerchantName())) throw new RRException("请输入商户姓名");
        if (StringUtils.isBlank(userEntity.getMerchantPhone())) throw new RRException("请输入商户电话");
        String successMessage = apiMerchantService.register(userEntity,request);
        return R.ok(successMessage);
    }

}
